import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialTypeVO, MaterialTypeForm, MaterialTypeQuery } from '@/api/agriculture/materialType/types';

/**
 * 查询农资类别列表
 * @param query
 * @returns {*}
 */

export const listMaterialType = (query?: MaterialTypeQuery): AxiosPromise<MaterialTypeVO[]> => {
  return request({
    url: '/agriculture/materialType/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询农资类别详细
 * @param materialTypeId
 */
export const getMaterialType = (materialTypeId: string | number): AxiosPromise<MaterialTypeVO> => {
  return request({
    url: '/agriculture/materialType/' + materialTypeId,
    method: 'get'
  });
};

/**
 * 新增农资类别
 * @param data
 */
export const addMaterialType = (data: MaterialTypeForm) => {
  return request({
    url: '/agriculture/materialType',
    method: 'post',
    data: data
  });
};

/**
 * 修改农资类别
 * @param data
 */
export const updateMaterialType = (data: MaterialTypeForm) => {
  return request({
    url: '/agriculture/materialType',
    method: 'put',
    data: data
  });
};

/**
 * 删除农资类别
 * @param materialTypeId
 */
export const delMaterialType = (materialTypeId: string | number | Array<string | number>) => {
  return request({
    url: '/agriculture/materialType/' + materialTypeId,
    method: 'delete'
  });
};
